package com.redepronik.negosys.invfac.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the detallecredito database table.
 * 
 */
@Entity
@Table(schema = "invfac", name = "detallecredito")
@NamedQuery(name = "Detallecredito.findAll", query = "SELECT d FROM Detallecredito d")
public class Detallecredito implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "DETALLECREDITO_DETALLECREDITOID_GENERATOR", sequenceName = "INVFAC.DETALLECREDITO_DETALLECREDITOID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DETALLECREDITO_DETALLECREDITOID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Integer detallecreditoid;

	@Column(nullable = false, precision = 20, scale = 10)
	private BigDecimal cuota;

	@Temporal(TemporalType.DATE)
	@Column(nullable = false)
	private Date fechalimite;

	@Temporal(TemporalType.DATE)
	@Column(nullable = false)
	private Date fechamora;

	@Temporal(TemporalType.DATE)
	private Date fechapago;

	@Column(precision = 20, scale = 10)
	private BigDecimal mora;

	@Column(nullable = false)
	private Integer orden;

	@Column(nullable = false)
	private Boolean pagado;

	@Column(nullable = false, precision = 20, scale = 10)
	private BigDecimal saldo;

	// bi-directional many-to-one association to Credito
	@ManyToOne
	@JoinColumn(name = "creditoid", nullable = false)
	private Credito credito;

	// bi-directional many-to-one association to Pagocredito
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "detallecredito")
	private List<Pagocredito> pagocreditos;

	public Detallecredito() {
	}

	public Pagocredito addPagocredito(Pagocredito pagocredito) {
		getPagocreditos().add(pagocredito);
		pagocredito.setDetallecredito(this);

		return pagocredito;
	}

	public Credito getCredito() {
		return this.credito;
	}

	public BigDecimal getCuota() {
		return this.cuota;
	}

	public Integer getDetallecreditoid() {
		return this.detallecreditoid;
	}

	public Date getFechalimite() {
		return this.fechalimite;
	}

	public Date getFechamora() {
		return this.fechamora;
	}

	public Date getFechapago() {
		return this.fechapago;
	}

	public BigDecimal getMora() {
		return this.mora;
	}

	public Integer getOrden() {
		return this.orden;
	}

	public Boolean getPagado() {
		return this.pagado;
	}

	public List<Pagocredito> getPagocreditos() {
		return this.pagocreditos;
	}

	public BigDecimal getSaldo() {
		return this.saldo;
	}

	public Pagocredito removePagocredito(Pagocredito pagocredito) {
		getPagocreditos().remove(pagocredito);
		pagocredito.setDetallecredito(null);

		return pagocredito;
	}

	public void setCredito(Credito credito) {
		this.credito = credito;
	}

	public void setCuota(BigDecimal cuota) {
		this.cuota = cuota;
	}

	public void setDetallecreditoid(Integer detallecreditoid) {
		this.detallecreditoid = detallecreditoid;
	}

	public void setFechalimite(Date fechalimite) {
		this.fechalimite = fechalimite;
	}

	public void setFechamora(Date fechamora) {
		this.fechamora = fechamora;
	}

	public void setFechapago(Date fechapago) {
		this.fechapago = fechapago;
	}

	public void setMora(BigDecimal mora) {
		this.mora = mora;
	}

	public void setOrden(Integer orden) {
		this.orden = orden;
	}

	public void setPagado(Boolean pagado) {
		this.pagado = pagado;
	}

	public void setPagocreditos(List<Pagocredito> pagocreditos) {
		this.pagocreditos = pagocreditos;
	}

	public void setSaldo(BigDecimal saldo) {
		this.saldo = saldo;
	}

}